import librosa
from librosa import feature
import numpy
import torch
import ims
melspecims=ims.IMS()
chromaims=ims.IMS()
contrastims=ims.IMS()
tonetzims=ims.IMS()
def fitterload(path):
    y,sr = librosa.load(path)
    melspec = librosa.feature.melspectrogram(y=y,sr=sr)
    chroma = librosa.feature.chroma_stft(y=y,sr=sr)
    contrast = librosa.feature.spectral_contrast(y=y,sr=sr)
    tonnetz = librosa.feature.tonnetz(y=y,sr=sr)
    #melspec = (melspec-numpy.mean(melspec))/numpy.std(melspec)
    melspec = melspecims(melspec)
    #chroma = chromaims(chroma)
    #chroma = (chroma-numpy.mean(chroma))/numpy.std(chroma)
    contrast = contrastims(contrast)
    tonnetz = tonetzims(tonnetz)
    #print(melspec.shape)
    return [melspec,chroma,contrast,tonnetz]
if __name__ == '__main__':
    fitterload(r'D:\old\Desktop\old\animal\barking-emotion-recognition\data\audioset_audios\0BwiOU6alvQ_0_10_cut.mp3')